package module;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import bean.User;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.Statement;

import DateBase.*;


public class UserModule {
	Datebase con=new Datebase();
	Connection conn=(Connection) con.getConnection();
	
	public ArrayList islogin(String P,String U) throws SQLException{
		
		String sql="select * from user where username='"+U+"'";
		Statement st=(Statement) conn.createStatement();
	   ResultSet rs =  st.executeQuery(sql);
	   ArrayList list=new ArrayList();
	   while(rs.next()){
		   User user=new User();
		   user.setUsername(rs.getString("username"));
		   if(rs.getString("userpassword").equals(P)){
			   user.setLoginflag(1);
			   user.setUserid(rs.getInt("userid"));
		   }
		   else
			   user.setLoginflag(0);
		   list.add(user);
	   }
	   //conn.close();
	   return list;
	}

	
}
